package com.xike.microemailserver.controller;
import com.xike.entiy.ResultBean;
import com.xike.microemailserver.service.IMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: masterhai
 * @date: 2021/4/6:9:24
 * @description:
 */
@RefreshScope
@Api(tags = "手机短信相关接口")
@RequestMapping(value = "/message", produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
public class MessageController {
    @Resource
    private IMessageService messageService;

    @ApiOperation("发送验证码")
    @PostMapping("send")
    public ResultBean sendMessage (@ApiParam("手机号") @RequestParam("phoneNum") String phoneNum,
                                   @RequestParam("msg") String msg) {
        if (StringUtils.isEmpty(phoneNum)) {
            return ResultBean.builder().code(600).msg("错误手机号").build();
        }
        return messageService.sendMessage(phoneNum,msg);
    }

//    @GetMapping("/sendMail")
//    public String sendSimpleMail () {
//        messageService.sendMail();
//        return "success";
//    }
}
